package com.nlx.notes.module.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nlx.notes.module.entity.AccountBooks;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 账本表 Mapper 接口
 * </p>
 *
 * @author nlx
 * @since 2025-11-28
 */
public interface AccountBooksMapper extends BaseMapper<AccountBooks> {

    /**
     * 查询用户的所有未删除账本，按创建时间倒序排列
     * @param userId 用户ID
     * @return 账本列表
     */
    @Select("SELECT * FROM account_books WHERE user_id = #{userId} AND del_flag = 0 ORDER BY created_time DESC")
    List<AccountBooks> selectByUserIdOrderByCreatedTimeDesc(@Param("userId") Long userId);
}